#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QNetworkReply>

QT_BEGIN_NAMESPACE
class APIBase;
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
    Q_OBJECT

public:
    enum Method {
        GET = 0,
        POST,
        PUT,
        HEAD,
        DELETE,
        OPTIONS,
        TRACE,
        CONNECT,
        LINK,
        UNLINK,
        MethodEnd
    };


    MainWindow(QWidget* parent = nullptr);
    ~MainWindow();

private slots:

    void on_btnRun_clicked();

    void httpRun(Method type);

    void connectNetworkReply(QNetworkReply* reply);
    void connectReplyToErrors(QNetworkReply* reply);

    void handleReplyError(QNetworkReply::NetworkError error);
    void handleSslErrors(QList<QSslError> errors);

    void networkReplyFinshSlot();

private:
    Ui::MainWindow* ui;
    APIBase* rest;
};

Q_DECLARE_METATYPE(MainWindow::Method)
#endif // MAINWINDOW_H
